<?php
	$root = sfConfig::get('sf_web_dir');	
	// 大图
	$b_img = '/images/products/b_img/';
	// 频图
	$f_img = '/images/products/f_img/';
	// 配件图高度213
	$a_img_dir = '/images/products/a_img/'.strtolower($product->getName()).'/';
	$dp = opendir($root.$a_img_dir);
	$a_imgs = array();
	if ($dp) {
		while (($curFile = readdir($dp)) !== false ) {		
			if ($curFile != '.'	&&	$curFile != '..' && $curFile != '') {			
				if (is_dir($root.$a_img_dir.$curFile)) { 				
				} else {				
					$a_imgs[] =  $a_img_dir.$curFile;				
				}
			}
		}
	}
	// 声音采样
	$sound_dir = '/images/products/sound_img/'.strtolower($product->getName()).'/';
	$dp = opendir($root.$sound_dir);
	$sounds = array();
	if ($dp) {
		while (($curFile = readdir($dp)) !== false ) {		
			if ($curFile != '.'	&&	$curFile != '..' && $curFile != '') {			
				if (is_dir($root.$sound_dir.$curFile)) { 				
				} else {				
					$sounds[] = array(
						'full' => $sound_dir.$curFile,
						'name' => $curFile
					);			
				}
			}
		}
	}
	// 声音采样文本说明
	$sound_txt = '/images/products/sound_txt/'.$product->getName().'.txt';
	$sound_txt_array = array();	
	if (file_exists($root.$sound_txt)) {
		$tmp = file_get_contents($root.$sound_txt);
	}
	$sound_txt_array = explode("\n", $tmp);	
?>
<script>
<!--
var lang = '<?php echo $lang; ?>';
var search_searies = function(series){
	if (series) {		
		var form = document.createElement('form');
		form.method = 'post';
		if (lang == 'en')
			form.action = '/products/en';
		else
			form.action = '/products';		
		var input = document.createElement('input');
		input.type = 'text';
		input.name = 'ed_series';
		input.value = series;		
		$(form).append(input);
		$(document.body).append(form);		
		$(form).submit();			
	}
};
//-->
</script>
<div id="product_nav">
	<a href="/"><?php echo __('首页'); ?></a>»<a href="/products"><?php echo __('产品介绍'); ?></a>»<a id="<?php echo $product->getSeries(); ?>" onclick="search_searies(this.id);"><?php echo $product->getSeries(); ?></a>»<a><?php echo $product->getName(); ?></a>
</div>
<div id="product_info">
	<div class="text">
		<div class="title">
			<div class="remarks1"><?php echo html_entity_decode($product->getRemarks1()); ?></div>		
			<div class="name"><?php echo $product->getName(); ?></div>
			<div class="clear"></div>
		</div>			
	<?php if ($lang == 'ch') { ?>
		<div class="content"><?php echo $product->getContent() ? $product->getContent() : '没有详细信息。'; ?></div>
	<?php } else { ?>
		<div class="content"><?php echo $product->getContentEn() ? $product->getContentEn() : 'no describute.'; ?></div>
	<?php } ?>
	<?php
		$img_src = strtolower($f_img.$product->getName().'.jpg');
		if (file_exists($root.$img_src)) {
	?>
		<div class="frequency_img"><img src="<?php echo $img_src; ?>" /></div>
	<?php
		}
		/*
	?>
		<div class="params">
			<span><?php echo __('响应频率'); ?>:&nbsp;&nbsp;&nbsp;&nbsp;</span><span><?php echo $product->getFrequency(); ?></span><br/>
			<span><?php echo __('指向模式'); ?>:&nbsp;&nbsp;&nbsp;&nbsp;</span><span><?php echo __($product->getPolar()); ?></span><br/>
			<span><?php echo __('灵敏度').'('.$product->getSensitivityUnit().')'; ?>:&nbsp;&nbsp;&nbsp;&nbsp;</span><span><?php echo $product->getSensitivity(); ?></span><br/>
			<?php if ($product->getOutputI() != '') { ?>
			<span><?php echo __('输出阻抗'); ?>:&nbsp;&nbsp;&nbsp;&nbsp;</span><span><?php echo $product->getOutputI(); ?></span><br/>
			<?php } ?>			
		</div>
	<?php
		*/
	?>
		<div class="params"><?php echo html_entity_decode($product->getParams()); ?></div>		
	</div>
	<div class="b_img">
		<div><img src="<?php
			$img_src = strtolower($b_img.$product->getName().'.jpg');			
			$default_img_src = $b_img.'0.jpg'; 			
			if (file_exists($root.$img_src))
				echo $img_src;
			else echo $default_img_src;
		?>" /></div>
		<div class="feature"><?php echo html_entity_decode($product->getRemarks()); ?></div>
	</div>	
	<div class="clear"></div>
	<div class="accessories">
		<div class="title"><?php echo __('配件'); ?></div>
		<div class="content">
		<?php 
			if (count($a_imgs) > 0) {
				foreach($a_imgs as $a_i) {	 
		?>
			<div class="item"><img src="<?php echo $a_i; ?>" /></div>
		<?php
				}
		?>
			<div class="clear"></div>
		<?php	 
			} else {
				if ($lang == 'ch') {
		?>
			<div class="empty">无配件</div>
		<?php 
				} else if ($lang =='en') {
		?>
			<div class="empty">No accessories.</div>
		<?php 
				}
			}
		?>
		</div>
	</div>
	<div class="sound_sampling">
		<div class="title"><?php echo __('声音采样'); ?></div>
		<div class="content">
		<?php
			if (count($sounds) > 0) {
				foreach($sounds as $i=>$s) {
		?>
			<div class="item">
				<a href="<?php echo $s['full']; ?>"><?php echo $s['name']; ?></a>
				<span><?php echo html_entity_decode($sound_txt_array[$i]) ;?></span>
				<div class="clear"></div>
			</div>
		<?php
				} 
		?>
			<div class="clear"></div>
		<?php
				
			} else { if ($lang == 'ch') {
		?>
			<div class="empty">无声音采样</div>
		<?php 
				} else if ($lang =='en') {
		?>
			<div class="empty">No sound sampling.</div>
		<?php 
				}
			}
		?>
		</div>
	</div>
</div>